package com.hjq.fcloud.config

import com.hjq.fcloud.http.api.FlowStatusApi

object FlowStatusConfig {
    //main_status：9表示重签
    private val MAIN_STATUS_AGAIN_SIGN: String = "9" //签约失败（进行重新签约）

    //finished（当前步骤是否完成 1完成 0未完成 -1当前步骤未达），如果是0，则表示可以签约，如果同时main_status=9，则表示重签
    private val FINISHED_ALL: String = "1"
    private val FINISHED_SIGN: String = "0"
    private val FINISHED_FLOW_UNFINISHED: String = "-1" //当前步骤未达

    /**
     * 展示前置流程未完成页面
     */
    fun isFlowUnfinished(flowStatusData: FlowStatusApi.FlowStatusData?):Boolean{
        var finished = flowStatusData?.finished
        return finished?.equals(FINISHED_FLOW_UNFINISHED) == true
    }

    /**
     * 能签约
     */
    fun canSign(flowStatusData: FlowStatusApi.FlowStatusData?):Boolean{
        var finished = flowStatusData?.finished
        return finished?.equals(FINISHED_SIGN) == true
    }

    /**
     * 能重新签约
     */
    fun canAgainSign(flowStatusData: FlowStatusApi.FlowStatusData?):Boolean{
        var mainStatus = flowStatusData?.main_status
        return canSign(flowStatusData) && mainStatus?.equals(MAIN_STATUS_AGAIN_SIGN) == true
    }

    /**
     * 判断是否签约成功
     * @return true 签约成功，false 签约失败，null其他状态
     */
    fun judgeSignSuccess(flowStatusData: FlowStatusApi.FlowStatusData?):Boolean?{
        var finished = flowStatusData?.finished
        var mainStatus = flowStatusData?.main_status
        if(finished.equals(FINISHED_ALL)){
            return true
        }else if(mainStatus.equals(MAIN_STATUS_AGAIN_SIGN)){
            return false
        }
        return null
    }

    /**
     * 获取文件标题
     */
    fun getFileTitleName(flowStatusData: FlowStatusApi.FlowStatusData?): String {
        var finished = flowStatusData?.finished
        var mainStatus = flowStatusData?.main_status
        if (finished.equals(FINISHED_ALL) || mainStatus.equals(MAIN_STATUS_AGAIN_SIGN)) {
            return "已签约文件"
        } else {
            return "待签约文件"
        }
    }
}